﻿using Aliphant.Datas;

namespace Aliphant.Interfaces
{
    public interface IContainer : IDisposable
    {
        /// <summary>
        /// 注册泛型服务
        /// </summary>
        /// <typeparam name="TService"></typeparam>
        /// <typeparam name="TImplementation"></typeparam>
        /// <param name="lifecycle"></param>
        /// <returns></returns>
        IContainer Register<TService, TImplementation>(LifecycleType lifecycle = LifecycleType.Transient) where TImplementation : TService;

        /// <summary>
        /// 注册非泛型服务
        /// </summary>
        /// <param name="serviceType"></param>
        /// <param name="implementationType"></param>
        /// <param name="lifecycle"></param>
        /// <returns></returns>
        IContainer Register(Type serviceType, Type implementationType, LifecycleType lifecycle = LifecycleType.Transient);

        /// <summary>
        /// 解析服务
        /// </summary>
        /// <param name="serviceType"></param>
        /// <returns></returns>
        object Resolve(Type serviceType);

        /// <summary>
        /// 解析服务
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        T Resolve<T>();

        /// <summary>
        /// 创建作用域
        /// </summary>
        /// <returns></returns>
        IScope CreateScope();
    }
}
